import 'package:Smart/config/init_config.dart';
import 'package:Smart/pages/main_page.dart';
import 'package:flutter/material.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:Smart/utils/routers/page_jump_service.dart';

///程序主入口
void main() {
  ///配置初始化
  InitConfig.instance();
  ///启动APP
  runApp(AppComponent());
}

///AppComponent类
class AppComponent extends StatefulWidget {
  @override
  _AppComponentState createState() => _AppComponentState();
}

class _AppComponentState extends State<AppComponent> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      ///1.配置支持国际化
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: [
        const Locale('en', 'US'), // 美国英语
        const Locale('zh', 'CN'), // 中文简体
        //其它Locales
      ],
      ///2.配置新页面跳转所需要的key
      navigatorKey: PageJumpService.instance().navigatorKey,

      title: 'Flutter Study',
      builder: BotToastInit(),
      home: MainPage(),
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
        primaryColor: Color(0xFF141413),
      ),
    );
  }
}